import java.util.Scanner;

class Person implements Cloneable{
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}


public class Test {
    public static void test1(int[] a) throws CloneNotSupportedException {
        if(a == null) {
            throw new CloneNotSupportedException();
        }
    }
    //笔试题
    public static int test2() {
        try {
            int a = 10;
            return a;
        }catch (NullPointerException e) {
            return 1;
        }finally {
            return 9;
        }
    }
    public static void main(String[] args) {
        System.out.println(test2());
    }

    public static void main7(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            //存放可能抛出异常的代码
            //test1(null);
//            int[] array = null;
//            System.out.println(array.length);
            int a = scanner.nextInt();
            int[] array = {1, 2, 3};
            System.out.println(array[10]);
        } catch (ArithmeticException e) {
            e.printStackTrace();
            System.out.println("捕捉到了 CloneNotSupportedException 异常，进行处理异常的逻辑");
        } catch (NullPointerException e) {
            System.out.println("捕获到了 NullPointerException 异常");
        } finally {
            System.out.println("finally一般用于资源的释放......");
        }
        System.out.println("正常的逻辑.......");
    }
    public static void main6(String[] args) {
        try {
            //存放可能抛出异常的代码
            //test1(null);
//            int[] array = null;
//            System.out.println(array.length);
            int[] array = {1,2,3};
            System.out.println(array[10]);
        }catch (ArithmeticException e) {
            e.printStackTrace();
            System.out.println("捕捉到了 CloneNotSupportedException 异常，进行处理异常的逻辑");
        }catch (NullPointerException e) {
            System.out.println("捕获到了 NullPointerException 异常");
        }finally {
            System.out.println("finally一般用于资源的释放......");
        }
        System.out.println("正常的逻辑.......");
    }
    public static void main5(String[] args) {
        try {
            //存放可能抛出异常的代码
            //test1(null);
            int[] array = null;
            System.out.println(array.length);

            System.out.println(10/0);
        }catch (NullPointerException e) {
            System.out.println("捕获到了 NullPointerException 异常");
        }catch (Exception e) {
            e.printStackTrace();
            System.out.println("捕捉到了 CloneNotSupportedException 异常，进行处理异常的逻辑");
        }
        System.out.println("正常的逻辑.......");
    }

    public static void main4(String[] args) {
        try {
            //存放可能抛出异常的代码
            //test1(null);
            int[] array = null;
            System.out.println(array.length);
        }catch (ArithmeticException | NullPointerException  e) {
            e.printStackTrace();
            System.out.println("捕捉到了 CloneNotSupportedException | NullPointerException 异常，进行处理异常的逻辑");
        }
        System.out.println("正常的逻辑.......");
    }
    public static void main3(String[] args) {
        try {
            //存放可能抛出异常的代码
            //test1(null);
            int[] array = null;
            System.out.println(array.length);
        }catch (ArithmeticException e) {
            e.printStackTrace();
            System.out.println("捕捉到了 CloneNotSupportedException 异常，进行处理异常的逻辑");
        }catch (NullPointerException e) {
            System.out.println("捕获到了 NullPointerException 异常");
        }
        System.out.println("正常的逻辑.......");
    }
    public static void func() {
        func();
    }

    public static void main2(String[] args) {
        func();
    }
    public static void main1(String[] args) throws CloneNotSupportedException {
        //System.out.println(10/0);

//        int[] array = null;
//        System.out.println(array.length);
//        System.out.println("sdadsa");

//        int[] array = {1,2,3};
//        System.out.println(array[10]);

        Person person = new Person();
        Person person1 = (Person) person.clone();

    }
}
